function [ outSt ] = merge_structs( oldSt, newSt )
%MERGE_STRUCTS Merges new fileds and new values of the fields from the new structure to the old structure.
% Function updates oldSt by adding new fileds and new values of existing fields that are found in
% newSt. Usefuld for merging user entered properties with default set of properties.
%
% Syntax:
%   out = merge_structs(oldSt, newSt)
% Inputs:
%   oldSt - Structure that is going to be edited.
%   newSt - Structure with new values and possible new fileds.
%
% Outputs:
%   outSt - Resulting structure after performing merge.
%
% Example:
%   def_params = struct('height', 100, 'width', 200);
%   usr_params = struct( 'width', 300, 'depth', 400);
%   params     = merge_structs(def_params, usr_params);
%
% See also: SELECT_FOLDER, SELECT_FILE

% Created on:    2014-01-04 (Dragomir El Mezeni)
% Last revision: 2014-01-04 (Dragomir El Mezeni)

%------------- BEGIN CODE --------------

% 1 - Performs merge.
outSt = oldSt;

names = fieldnames(newSt);
for i=1:length(names)
    outSt.(names{i}) =  newSt.(names{i});
end
